﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class XuanzhuanAnniuController : MonoBehaviour {

    private bool b_isDown;
    private float f_xuanzhuanTime = 0.0f;

    // Use this for initialization
    void Update () {
        if (b_isDown) {
            f_xuanzhuanTime += Time.deltaTime;
            EventManager<string>.TriggerEvent(MyEventType.OnllyXuanzhuan, gameObject.name);
            if (f_xuanzhuanTime >= 0.5f) {
                f_xuanzhuanTime = 0;
                EventManager<string>.TriggerEvent(MyEventType.XuanzhuanAnniuEvent, gameObject.name);
            }
        }
	}

    void OnMouseDown() {
        if (!OnllyUIController._instance.b_isHeiPing)
        {
            EventManager<string>.TriggerEvent(MyEventType.OnllyXuanzhuan, gameObject.name);
            f_xuanzhuanTime = 0.0f;
            b_isDown = true;
            OnllyUIController._instance.ChangeZhishideng(false, 0.5f);
        }
    }

    void OnMouseUp() {
        if (!OnllyUIController._instance.b_isHeiPing)
        {
            b_isDown = false;
            EventManager<string>.TriggerEvent(MyEventType.XuanzhuanAnniuEvent, gameObject.name);
        }
    }
}
